'************************************************************************************
' Copyright © 2003-2005 Kathleen Dollard
'
' This software is provided 'as-is', without any express or implied warranty. In no 
' event will the author be held liable for any damages arising from the use of this
' software.
' 
' You may use this software for any purpose, including commercial applications, 
' and you may redistribute this software as part of application delivery: however, 
' this copyright notice may not be removed and you may not otherwise redistribute 
' this software directly other than providing a link to wwww.gendotnet.com. 
'
' You may alter this software to better server your needs (I'd like to hear about your 
' changes in order to make the software better). If you alter the softwre, you must  
' clearly mark it as altered and must not be misrepresented as the original software.
' nor wholly your original work.
'*************************************************************************************
Option Strict On
Option Explicit On 

Imports System

Namespace KADGen.CodeGenerationSupport
   Public Class OutputEntryDefinition
#Region "Class level declarations"
      Private Shared mPropertyInfo() As PropertyInfo
#End Region

#Region "Shared Methods"
      Private Shared Sub SetDefinition()
         If mPropertyInfo Is Nothing Then
            ReDim mPropertyInfo(13)
            mPropertyInfo(0) = New PropertyInfo("Status", GetType(CodeGenerationSupport.OutputStatus), 100, False)
            mPropertyInfo(1) = New PropertyInfo("StatusIcon", "", GetType(CodeGenerationSupport.OutputStatus), 18, False)
            mPropertyInfo(2) = New PropertyInfo("FileName", GetType(String), 200, False)
            mPropertyInfo(3) = New PropertyInfo("ShortFileName", GetType(String), 100, False)
            mPropertyInfo(4) = New PropertyInfo("FileTreatment", GetType(CodeGenerationSupport.FileTreatment), 100, False)
            mPropertyInfo(5) = New PropertyInfo("DirectiveType", GetType(String), 100, False)
            mPropertyInfo(6) = New PropertyInfo("SectionName", GetType(String), 100, False)
            mPropertyInfo(7) = New PropertyInfo("DirectiveName", GetType(String), 100, False)
            mPropertyInfo(8) = New PropertyInfo("Message", GetType(String), 100, False)
            mPropertyInfo(9) = New PropertyInfo("DateTime", GetType(DateTime), 100, False)
            mPropertyInfo(10) = New PropertyInfo("Category", GetType(String), 100, False)
            mPropertyInfo(11) = New PropertyInfo("Source", GetType(String), 100, False)
            mPropertyInfo(12) = New PropertyInfo("Title", GetType(String), 100, False)
            mPropertyInfo(13) = New PropertyInfo("Exception", GetType(System.Exception), 100, False)
         End If
      End Sub

      Public Shared ReadOnly Property PropertyCount() As Int32
         Get
            If mPropertyInfo Is Nothing Then
               SetDefinition()
            End If
            Return mPropertyInfo.Length
         End Get
      End Property

      Public Shared ReadOnly Property PropertyMappingName(ByVal index As Int32) As String
         Get
            If mPropertyInfo Is Nothing Then
               SetDefinition()
            End If
            Return mPropertyInfo(index).MappingName
         End Get
      End Property

      Public Shared ReadOnly Property PropertyCaption(ByVal index As Int32) As String
         Get
            If mPropertyInfo Is Nothing Then
               SetDefinition()
            End If
            Return mPropertyInfo(index).Caption
         End Get
      End Property

      Public Shared ReadOnly Property PropertyMenuEntry(ByVal index As Int32) As String
         Get
            Dim ret As String
            ret = PropertyCaption(index)
            If ret Is Nothing OrElse ret.Trim.Length = 0 Then
               ret = Utility.Tools.SpaceAtCaps(PropertyMappingName(index))
            End If
            Return ret
         End Get
      End Property

      Public Shared ReadOnly Property PropertyType(ByVal index As Int32) As System.Type
         Get
            If mPropertyInfo Is Nothing Then
               SetDefinition()
            End If
            Return mPropertyInfo(index).Type
         End Get
      End Property

      Public Shared ReadOnly Property PropertyWidth(ByVal index As Int32) As Int32
         Get
            If mPropertyInfo Is Nothing Then
               SetDefinition()
            End If
            Return mPropertyInfo(index).Width
         End Get
      End Property

      Public Shared ReadOnly Property PropertyHidden(ByVal index As Int32) As Boolean
         Get
            If mPropertyInfo Is Nothing Then
               SetDefinition()
            End If
            Return mPropertyInfo(index).Hidden
         End Get
      End Property

      Public Shared ReadOnly Property PropertyOrdinal(ByVal name As String) As Int32
         Get
            If mPropertyInfo Is Nothing Then
               SetDefinition()
            End If
            For i As Int32 = 0 To mPropertyInfo.GetUpperBound(0)
               If mPropertyInfo(i).MappingName = name Then
                  Return i
               End If
            Next
         End Get
      End Property
#End Region

      Private Class PropertyInfo
         Public MappingName As String
         Public Caption As String
         Public Type As System.Type
         Public Width As Int32
         Public Hidden As Boolean
         Public Sub New( _
                  ByVal mappingName As String, _
                  ByVal caption As String, _
                  ByVal type As System.Type, _
                  ByVal width As Int32, _
                  ByVal hidden As Boolean)
            Me.MappingName = mappingName
            Me.Caption = caption
            Me.Type = type
            Me.Width = width
            Me.Hidden = hidden
         End Sub
         Public Sub New( _
                  ByVal mappingName As String, _
                  ByVal type As System.Type, _
                  ByVal width As Int32, _
                  ByVal hidden As Boolean)
            Me.MappingName = mappingName
            Me.Caption = Utility.Tools.SpaceAtCaps(mappingName)
            Me.Type = type
            Me.Width = width
            Me.Hidden = hidden
         End Sub

      End Class

   End Class
End Namespace